SlideShare a Scribd company logo
1 of 24
The Chinese University of Hong Kong                                      Fall 2011

CSCI 3130: Automata theory and formal languages




                   Non-regular languages



                                                                 Andrej Bogdanov
                                       http://www.cse.cuhk.edu.hk/~andrejb/csc3130
A non-regular language
• An example

    L = {0n1n: n ≥ 0} is not regular.

• We reason by contradiction:
  – Suppose we have managed to construct a DFA M for L
  – We argue something must be wrong with this DFA
  – In particular, M must accept some strings outside L
A non-regular language
                            imaginary DFA for L with n states
                                                          M
   x




• What happens when we run M on input x = 0n+11n+1?
   – M better accept, because x ∈ L
A non-regular language

                                     0                     M
   x         0         0         0         0

                                         0r1n+1


• What happens when we run M on input x = 0n+11n+1?
   – M better accept, because x ∈ L
   – But since M has n states, it must revisit at least one of its
     states while reading 0n+1
Pigeonhole principle

    Suppose you are tossing n + 1 balls into n bins.
    Then two balls end up in the same bin.


• Here, balls are 0s, bins are states:


    If you have a DFA with n states and it reads
    n + 1 consecutive 0s, then it must end up in the
    same state twice.
A non-regular language

                                     0                     M
   x         0         0         0         0

                                         0r1n+1


• What happens when we run M on input x = 0n+11n+1?
   – M better accept, because x ∈ L2
   – But since M has n states, it must revisit at least one of its
     states while reading 0n+1
   – But then the DFA must contain a loop with 0s
A non-regular language

                               0                M
           0       0       0         0

                                   0r1n+1


• The DFA will then also accept strings that go around
  the loop multiple times
• But such strings have more 0s than 1s, so they are
  not in L2!
General method for showing non-regularity
• Every regular language L has a property:

                              an
   z       a1       ak    ak+1 … an-1
                …

                             an+1…am



• For every sufficiently long input z in L, there is a
  “middle part” in z that, even if repeated any number
  of times, keeps the input inside L
Pumping lemma for regular languages
• Pumping lemma: For every regular language L

     There exists a number n such that for every
     string z in L, we can write z = u v w where
        |uv| ≤ n
        |v| ≥ 1
        For every i ≥ 0, the string u vi w is in L.


                                v
 z              …               …
                 u                  w
Arguing non-regularity
• If L is regular, then:
     There exists n such that for every z in L, we can
     write z = u v w where |uv| ≤ n, |v| ≥ 1 and
      For every i ≥ 0, the string u vi w is in L.

• So to prove L is not regular, it is enough to show:
     For every n there exists z in L, such that for
     every way of writing z = u v w where
     |uv| ≤ n and |v| ≥ 1, the string u vi w is not in
     L for some i ≥ 0.
Proving non regularity
   For every n there exists z in L, such that for
   every way of writing z = u v w where
   |uv| ≤ n and |v| ≥ 1, the string u vi w is not in
   L for some i ≥ 0.

• This is a game between you and an imagined
  adversary (say Donald)
      Donald                            you
   1 choose n                           choose z ∈ L
   2 write z = uvw (|uv| ≤ n,|v| ≥ 1)   choose i
                                        you win if uviw ∉ L
Arguing non-regularity
• You need to give a strategy that, regardless of what
  the adversary does, always wins you the game

      Donald                            you
   1 choose n                           choose z ∈ L
   2 write z = uvw (|uv| ≤ n,|v| ≥ 1)   choose i
                                        you win if uviw ∉ L
Example
     Donald                               you
  1 choose n                              choose z ∈ L
  2 write z = uvw (|uv| ≤ n,|v| ≥ 1)      choose i
                                          you win if uviw ∉ L
  L = {0n1n: n ≥ 0}

     Donald                               you
  1 choose n                              z = 0n1n
  2 write z = uvw                         i=2
     000000000000000111111111111111       uv2w = 0n+k1n ∉ L
          u     v        w
     0000000000000000000111111111111111
          u     v   v         w
Example

  LDUP = {0n10n1: n ≥ 0}

    Donald                                you
  1 choose n                              z = 0n10n1
  2 write z = uvw                         i=2
                                          uv2w = 0n+k10n1 ∉ L

     000000000000001000000000000001
         u      v        w

     0000000000000000001000000000000001
         u      v   v         w
Which of these are regular?

L1 = {x: x has same number of 0s and 1s}            Σ = {0, 1}
L2 = {x: x = 0n1m, n > m ≥ 0}
L3 = {x: x has same number of patterns 01 and 10}
L4 = {x: x has same number of patterns 01 and 10}
L5 = {x: x has different number of 0s and 1s}
Example

  L1 = {x: x has same number of 0s and 1s}


    Donald                                you
  1 choose n                              z = 0n1n
  2 write z = uvw                         i=2
                                          uv2w = 0n+k1n ∉ L3
     000000000000000111111111111111
         u      v        w
     0000000000000000000111111111111111
         u      v   v         w
Example

  L2 = {x: x = 0m1n, m > n ≥ 0}


    Donald                            you
  1 choose n                          z = 0n+11n
  2 write z = uvw                     i=0
                                      uv0w    = 0j+l1n+1 ∉ L2

     000000000000000111111111111111
         u      v        w

     00000000000111111111111111
         u          w
Example

  L3 = {x: x has same number of 01s and 11s}


    Donald                        you
  1 choose n                      z = (01)n(11)n
    n=1                           z = 0111 ∉ L4
                     has too many 11s
  What we have in mind:
    n=1        z = 011                     z = (01)n1n
    n=2        z = 010111
                                        has n 01s and n 11s
    n=3        z = 010101111
Example

  L3 = {x: x has same number of 01s and 11s}


    Donald                            you win!
  1 choose n                          z = (01)n1n
  2 write z = uvw                     i=0

         010101010101010111111111   Taking out v will kill
           u    v       w
                                    at least one 01,
         010101010101010111111111   but it does not kill any 11s
    or     u    v       w
    or   010101010101010111111111   so uv0w ∉ L3
          u v           w
Example

  L4 = {x: x has same number of 01s and 01s}


    Donald                        you
  1 choose n                      z = (01)n(10)n



    n=1        z = 0110
    n=2        z = 01011010

    n=3        z = 010101101010
Example

  L4 = {x: x has same number of 01s and 10s}
                                                        is regular!
    Donald                               you
  1 choose n                             z = (01)n(10)n
  2 write z = uvw                        i=20

                     5 01 patterns
                     5 10 patterns
    010101101010
    u v     w
                     6 01 patterns                4 01 patterns
                     6 10 patterns                4 10 patterns
    01010101101010                   0101101010
    u v v       w                    u      w
Example

                        1            0   one more 10
                            0
                   r0           r1
               1            1

          q0
               0        0            1   one more 01
                            1
                   s0           s1
                            0




     L4 = {x: x has same number of 01s and 10s}
Example

  L4 = {x: x has different number of 0s than 1s}


    Donald                            you
  1 choose n                          z=?

        there is an easier way!
  L1 = {x: x has same number of 0s and 1s} = L4

  If L4 is regular, then L1 = L4 is also regular
  But L1 is not regular, so L4 cannot be regular
Extra example

  L5 = {1p: p is prime}


      Donald                           you
  1 choose n                           z = 1p: p > n is prime
  2   write z = uvw = 1a1b1c           i=?+c
                                          a
                                       uviw   = 1a1ib1c
                                              = 1(a+c)+ib
      111111111111111111111111111111
       u = 1a   v = 1b   w = 1c               = 1(a+c)+(a+c)b
                                              = 1(a+c)(b+1)
                                              = 1composite ∉ L5

More Related Content

Similar to 11 l06

Similar to 11 l06 (20)

Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
PART B.docx
PART B.docxPART B.docx
PART B.docx
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
 
Deciding language inclusion problems using quasiorders
Deciding language inclusion problems using quasiordersDeciding language inclusion problems using quasiorders
Deciding language inclusion problems using quasiorders
 
Dfa basics
Dfa basicsDfa basics
Dfa basics
 
Dfa basics
Dfa basicsDfa basics
Dfa basics
 
Pumping lemma (1)
Pumping lemma (1)Pumping lemma (1)
Pumping lemma (1)
 
Linear algebra
Linear algebraLinear algebra
Linear algebra
 
Top school in ghaziabad
Top school in ghaziabadTop school in ghaziabad
Top school in ghaziabad
 
Koc2(dba)
Koc2(dba)Koc2(dba)
Koc2(dba)
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
unit 2 part b.docx
unit 2 part b.docxunit 2 part b.docx
unit 2 part b.docx
 
FSM.pdf
FSM.pdfFSM.pdf
FSM.pdf
 
Improper
ImproperImproper
Improper
 
Fourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 lFourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 l
 
Ch 04 Arithmetic Coding ( P P T)
Ch 04  Arithmetic  Coding ( P P T)Ch 04  Arithmetic  Coding ( P P T)
Ch 04 Arithmetic Coding ( P P T)
 
Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)
 
Legendre functions
Legendre functionsLegendre functions
Legendre functions
 

Recently uploaded

Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 

Recently uploaded (20)

Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 

11 l06

  • 1. The Chinese University of Hong Kong Fall 2011 CSCI 3130: Automata theory and formal languages Non-regular languages Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
  • 2. A non-regular language • An example L = {0n1n: n ≥ 0} is not regular. • We reason by contradiction: – Suppose we have managed to construct a DFA M for L – We argue something must be wrong with this DFA – In particular, M must accept some strings outside L
  • 3. A non-regular language imaginary DFA for L with n states M x • What happens when we run M on input x = 0n+11n+1? – M better accept, because x ∈ L
  • 4. A non-regular language 0 M x 0 0 0 0 0r1n+1 • What happens when we run M on input x = 0n+11n+1? – M better accept, because x ∈ L – But since M has n states, it must revisit at least one of its states while reading 0n+1
  • 5. Pigeonhole principle Suppose you are tossing n + 1 balls into n bins. Then two balls end up in the same bin. • Here, balls are 0s, bins are states: If you have a DFA with n states and it reads n + 1 consecutive 0s, then it must end up in the same state twice.
  • 6. A non-regular language 0 M x 0 0 0 0 0r1n+1 • What happens when we run M on input x = 0n+11n+1? – M better accept, because x ∈ L2 – But since M has n states, it must revisit at least one of its states while reading 0n+1 – But then the DFA must contain a loop with 0s
  • 7. A non-regular language 0 M 0 0 0 0 0r1n+1 • The DFA will then also accept strings that go around the loop multiple times • But such strings have more 0s than 1s, so they are not in L2!
  • 8. General method for showing non-regularity • Every regular language L has a property: an z a1 ak ak+1 … an-1 … an+1…am • For every sufficiently long input z in L, there is a “middle part” in z that, even if repeated any number of times, keeps the input inside L
  • 9. Pumping lemma for regular languages • Pumping lemma: For every regular language L There exists a number n such that for every string z in L, we can write z = u v w where  |uv| ≤ n  |v| ≥ 1  For every i ≥ 0, the string u vi w is in L. v z … … u w
  • 10. Arguing non-regularity • If L is regular, then: There exists n such that for every z in L, we can write z = u v w where |uv| ≤ n, |v| ≥ 1 and  For every i ≥ 0, the string u vi w is in L. • So to prove L is not regular, it is enough to show: For every n there exists z in L, such that for every way of writing z = u v w where |uv| ≤ n and |v| ≥ 1, the string u vi w is not in L for some i ≥ 0.
  • 11. Proving non regularity For every n there exists z in L, such that for every way of writing z = u v w where |uv| ≤ n and |v| ≥ 1, the string u vi w is not in L for some i ≥ 0. • This is a game between you and an imagined adversary (say Donald) Donald you 1 choose n choose z ∈ L 2 write z = uvw (|uv| ≤ n,|v| ≥ 1) choose i you win if uviw ∉ L
  • 12. Arguing non-regularity • You need to give a strategy that, regardless of what the adversary does, always wins you the game Donald you 1 choose n choose z ∈ L 2 write z = uvw (|uv| ≤ n,|v| ≥ 1) choose i you win if uviw ∉ L
  • 13. Example Donald you 1 choose n choose z ∈ L 2 write z = uvw (|uv| ≤ n,|v| ≥ 1) choose i you win if uviw ∉ L L = {0n1n: n ≥ 0} Donald you 1 choose n z = 0n1n 2 write z = uvw i=2 000000000000000111111111111111 uv2w = 0n+k1n ∉ L u v w 0000000000000000000111111111111111 u v v w
  • 14. Example LDUP = {0n10n1: n ≥ 0} Donald you 1 choose n z = 0n10n1 2 write z = uvw i=2 uv2w = 0n+k10n1 ∉ L 000000000000001000000000000001 u v w 0000000000000000001000000000000001 u v v w
  • 15. Which of these are regular? L1 = {x: x has same number of 0s and 1s} Σ = {0, 1} L2 = {x: x = 0n1m, n > m ≥ 0} L3 = {x: x has same number of patterns 01 and 10} L4 = {x: x has same number of patterns 01 and 10} L5 = {x: x has different number of 0s and 1s}
  • 16. Example L1 = {x: x has same number of 0s and 1s} Donald you 1 choose n z = 0n1n 2 write z = uvw i=2 uv2w = 0n+k1n ∉ L3 000000000000000111111111111111 u v w 0000000000000000000111111111111111 u v v w
  • 17. Example L2 = {x: x = 0m1n, m > n ≥ 0} Donald you 1 choose n z = 0n+11n 2 write z = uvw i=0 uv0w = 0j+l1n+1 ∉ L2 000000000000000111111111111111 u v w 00000000000111111111111111 u w
  • 18. Example L3 = {x: x has same number of 01s and 11s} Donald you 1 choose n z = (01)n(11)n n=1 z = 0111 ∉ L4 has too many 11s What we have in mind: n=1 z = 011 z = (01)n1n n=2 z = 010111 has n 01s and n 11s n=3 z = 010101111
  • 19. Example L3 = {x: x has same number of 01s and 11s} Donald you win! 1 choose n z = (01)n1n 2 write z = uvw i=0 010101010101010111111111 Taking out v will kill u v w at least one 01, 010101010101010111111111 but it does not kill any 11s or u v w or 010101010101010111111111 so uv0w ∉ L3 u v w
  • 20. Example L4 = {x: x has same number of 01s and 01s} Donald you 1 choose n z = (01)n(10)n n=1 z = 0110 n=2 z = 01011010 n=3 z = 010101101010
  • 21. Example L4 = {x: x has same number of 01s and 10s} is regular! Donald you 1 choose n z = (01)n(10)n 2 write z = uvw i=20 5 01 patterns 5 10 patterns 010101101010 u v w 6 01 patterns 4 01 patterns 6 10 patterns 4 10 patterns 01010101101010 0101101010 u v v w u w
  • 22. Example 1 0 one more 10 0 r0 r1 1 1 q0 0 0 1 one more 01 1 s0 s1 0 L4 = {x: x has same number of 01s and 10s}
  • 23. Example L4 = {x: x has different number of 0s than 1s} Donald you 1 choose n z=? there is an easier way! L1 = {x: x has same number of 0s and 1s} = L4 If L4 is regular, then L1 = L4 is also regular But L1 is not regular, so L4 cannot be regular
  • 24. Extra example L5 = {1p: p is prime} Donald you 1 choose n z = 1p: p > n is prime 2 write z = uvw = 1a1b1c i=?+c a uviw = 1a1ib1c = 1(a+c)+ib 111111111111111111111111111111 u = 1a v = 1b w = 1c = 1(a+c)+(a+c)b = 1(a+c)(b+1) = 1composite ∉ L5